//
//  HomePageADTableViewCell.m
//  KuWoCan
//
//  Created by 周小宏 on 2017/4/20.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "HomePageADTableViewCell.h"
#import "SDCycleScrollView.h"

@interface HomePageADTableViewCell ()<SDCycleScrollViewDelegate>

@property (nonatomic, strong) SDCycleScrollView *cycleScrollView;
@end

@implementation HomePageADTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        self.cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage imageNamed:kPlacehodelImg]];
        self.cycleScrollView.backgroundColor = [UIColor whiteColor];
        self.cycleScrollView.showPageControl = NO;
        self.cycleScrollView.autoScrollTimeInterval = 3;
//        self.cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
        self.cycleScrollView.currentPageDotColor = KwBlueColor; // 自定义分页控件小圆标颜色
        self.cycleScrollView.pageDotColor = [UIColor grayColor];
        [self.contentView addSubview:self.cycleScrollView];

        self.cycleScrollView.layer.cornerRadius = 5 * screenW_6;
        self.cycleScrollView.layer.masksToBounds = YES;

        [self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(0, 10 * screenW_6, 0, 10 * screenW_6));
        }];
    }
    return self;
}

- (void)setAdCellTitlesGroup:(NSArray<NSString *> *)titlesGroup imageURLStringsGroup:(NSArray<NSString *> *)imageURLStringsGroup {
    self.cycleScrollView.titlesGroup = titlesGroup;
    self.cycleScrollView.imageURLStringsGroup = imageURLStringsGroup;
}

#pragma mark - Delegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    if (self.adCellClicked) {
        self.adCellClicked(index);
    }
}
@end
